

import requests
from lxml import etree

url = 'https://spiderbuf.cn/web-scraping-practice/scraper-via-http-post'

my_headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 '
                  'Safari/537.36 Edg/134.0.0.0 ',

}

payload = {
    'level': '8'
}

response = requests.post(url, headers=my_headers, data=payload).text


root = etree.HTML(response)
trs = root.xpath('//tr')
for tr in trs:
    tds = tr.xpath('./td')
    s = ''
    for td in tds:
        # print(td.text)
        s = s + str(td.text) + '|'
    print(s)

